home *** CD-ROM | disk | FTP | other *** search
- ; Assembly language routines for FCOPY
-
- ; (C) Copyright, Peter Norton 1983-4
-
- ; 01 Jun 84 -- minor changes made for free distribution
-
- ; 28 Oct 83 -- change disk functions to report error codes
-
- ; 25 oct 83 -- chrget added (from prod-200/magic83d)
- ; ifchr added (returns 0 if no character)
- ; lobeep added
-
- ; 28 july 83 -- written
-
- ; full track (8-sector) read, write, format, verify
-
- ; function readt (drive,track,segment,offset) : word
- ; writt
- ; formt return 0 if ok, error code in hi byte
- ; verit
-
- magic segment 'code'
- assume cs:magic
-
- public ifchr
- public chrget
- public readt
- public writt
- public formt
- public verit
-
- ; --------------------------------------------------------------------
-
- ; Copyright notice
-
- cright proc far
- db ' (C) Copyright 1983-4, Peter Norton '
- cright endp
-
- ; --------------------------------------------------------------------
-
- ; IFCHR like chrget, but doesn't wait for keystroke
- ;
- ; procedure ifchr (var x: word);
- ; external;
-
- ifchr proc far
- push bp
- mov bp,sp
- mov ah,1
- int 16h
- mov ax,0 ; set zero
- jz ifchr_ret ; if no code, skip
- mov ah,0 ; else read the code
- int 16h
- ifchr_ret:
- mov bp,[bp+06]
- mov [bp],ax
- pop bp
- ret 2
- ifchr endp
-
- ; --------------------------------------------------------------------
-
- ; CHRGET gets a keyboard character, with special indication
- ;
- ; tested 6/20/82 (both assembly and Pascal)
- ;
- ; procedure chrget (var x: word);
- ; external;
-
- chrget proc far
- push bp
- mov bp,sp
- mov ah,0
- int 16h
- mov bp,[bp+06]
- mov [bp],ax
- pop bp
- ret 2
- chrget endp
-
-
- ; --------------------------------------------------------------------
-
- readt proc far
- push bp
- mov bp,sp
- mov dl,[bp+12] ; drive
- mov dh,0 ; head (always zero)
- mov ch,[bp+10] ; track
- mov cl,1 ; sector number
- mov ax,[bp+08] ; segment
- mov es,ax
- mov bx,[bp+06] ; offset
- mov ah,2 ; service number 2 = read
- mov al,8 ; number of sectors
- int 13h
- mov al,1 ; assume bad (true)
- jc readt_return ; test carry (is set, bad)
- mov ax,0 ; set good (false)
- readt_return:
- pop bp
- ret 8
-
- readt endp
-
- ; --------------------------------------------------------------------
-
- writt proc far
- push bp
- mov bp,sp
- mov dl,[bp+12] ; drive
- mov dh,0 ; head (always zero)
- mov ch,[bp+10] ; track
- mov cl,1 ; sector number
- mov ax,[bp+08] ; segment
- mov es,ax
- mov bx,[bp+06] ; offset
- mov ah,3 ; service number 3 = write
- mov al,8 ; number of sectors
- int 13h
- mov al,1 ; assume bad (true)
- jc writt_return ; test carry (is set, bad)
- mov ax,0 ; set good (false)
- writt_return:
- pop bp
- ret 8
-
- writt endp
-
- ; --------------------------------------------------------------------
-
- formt proc far
- push bp
- mov bp,sp
- mov dl,[bp+12] ; drive
- mov dh,0 ; head (always zero)
- mov ch,[bp+10] ; track
- mov cl,1 ; sector number
- mov ax,[bp+08] ; segment
- mov es,ax
- mov bx,[bp+06] ; offset
- mov ah,5 ; service number 5 = format
- mov al,8 ; number of sectors
- int 13h
- mov al,1 ; assume bad (true)
- jc formt_return ; test carry (is set, bad)
- mov ax,0 ; set good (false)
- formt_return:
- pop bp
- ret 8
-
- formt endp
-
- ; --------------------------------------------------------------------
-
- verit proc far
- push bp
- mov bp,sp
- mov dl,[bp+12] ; drive
- mov dh,0 ; head (always zero)
- mov ch,[bp+10] ; track
- mov cl,1 ; sector number
- mov ax,[bp+08] ; segment
- mov es,ax
- mov bx,[bp+06] ; offset
- mov ah,4 ; service number 4 = verify
- mov al,8 ; number of sectors
- int 13h
- mov al,1 ; assume bad (true)
- jc verit_return ; test carry (is set, bad)
- mov ax,0 ; set good (false)
- verit_return:
- pop bp
- ret 8
-
- verit endp
-
- ; --------------------------------------------------------------------
-
-
- magic ends
-
- end
-